#encoding=utf8
import sys


def escape_unicode(txt):
  x = eval ("u\"\"\"" + txt + " \"\"\"");
  return x

def escape_html(text):
  result = ""
  start = text.find("&#")
  end = 0

  while start >= 0:
    if end < start: result += text[end : start]
    end = text.find(";", start + 2)
    if end > start:
      try:
        value = int(text[start + 2 : end])
	result += unichr(value)
      except:
        result += text[start : end + 1]
      end += 1
      start = text.find("&#", end)
    else:
      break
  
  if end < len(text):
    result += text[end:]
  return result


if __name__ == "__main__":
  if len(sys.argv) < 3:
    print "usage: %s [input file name] [output file name]" % sys.argv[0]
  else:
    fin = open(sys.argv[1], "r")
    fout = open(sys.argv[2], "w")
    data = fin.read()
    fin.close()
    #result = escape_html(data)
    result = escape_unicode(data)
    #print type(result)
    #print result.encode("utf8")
    #fout.write(unicode(result, "gbk").encode("utf8"))
    fout.write(result.encode("utf8"))
    fout.close()